package TUILayer;//makes this class a part of the TUILayer package
import java.util.*;
import ControlLayer.*;//The TUILayer needs to know the ControlLayer
/**
 * 
 * User interface - main menu

 * @author (Brian, Jesper, Jesper og  Hoang) 
 * @version ()

 */
public class MainMenuUI
{
  //Instance variabler
   private LagerUI lagerUI;
   private KundeUI kundeUI;
   private OrderUI orderUI;
   
   //Constructor
   public MainMenuUI()
   {
       
      
   }
   
   //Metode til at starte main menu
   public void mainMenuStart()
   {
        boolean exit=false;
        while (!exit)
        {
            int choise = writeMainMenu();
            if(choise == 1)
            {
                startKunde();
            }
            else{
                    if(choise == 2)
                    { 
                        startOrder();
                    }
                    else
                    {
                        if(choise == 3)
                        {
                            startLager();    
                        }//end if
                        else
                        {
                            if(choise == 4)
                            {
                                writeEnd();
                                exit = true;
                            }
                            else
                            {
                                System.out.println("Forkert input. Prøv igen!");
                                pause();
                            }
                        }//end else
                    }// end else
             }//end else
        }//end while
    }//end start
   
    //Metode til at udskrive main menu
   private int writeMainMenu()
    {       
            // creates a keyboard object to read input
            Scanner keyboard = new Scanner(System.in);
            System.out.println("\f *** MainMenu ***");
            System.out.println(" (1) Kunder");
            System.out.println(" (2) Order");
            System.out.println(" (3) Lager");
            System.out.println(" (4) Close");
            System.out.print("\n Indtast valg: ");
            
            
            int choise = keyboard.nextInt();
            
            return choise;
            
    }
    
    //Metode til at starte kunde UI
    private void startKunde()
    {
        kundeUI= new KundeUI();
        kundeUI.start();
    }

    //Metode til at starte order UI
    private void startOrder()
    {
        orderUI= new OrderUI();
        orderUI.start();
    }
    
    //Metode til at starte lager UI
    private void startLager()
    {
        lagerUI = new LagerUI();
        lagerUI.start();
    }
    
    //Metode til at printe besked når systemet lukkes
    private void writeEnd()
    {
        System.out.println(" The System is shuting down ");
    }
    
    //Metode til at pause menuen
    private void pause()
    {
        Scanner keyboard = new Scanner(System.in);
        String vent = keyboard.nextLine();
    }
 }
